#include "StdAfx.h"
#include "ZCommonModel.h"

ZCommonModel::ZCommonModel(VOID)
{
	m_ControlScale[0] = m_ControlScale[1] = m_ControlScale[2] = 1.0f;
	ZeroMemory( m_ControlRotate, sizeof(m_ControlRotate) );
	ZeroMemory( m_ControlTranslate, sizeof(m_ControlTranslate) );
}

ZCommonModel::~ZCommonModel(VOID)
{
}

VOID ZCommonModel::Set_ControlScale( INT a_Key, FLOAT a_Value )
{
	m_ControlScale[a_Key] = a_Value;
}

VOID ZCommonModel::Set_ControlRotate( INT a_Key, FLOAT a_Value )
{
	m_ControlRotate[a_Key] = a_Value;
}

VOID ZCommonModel::Set_ControlTranslate( INT a_Key, FLOAT a_Value )
{
	m_ControlTranslate[a_Key] = a_Value;
}

D3DXMATRIXA16 ZCommonModel::Get_MatWorld()
{
	D3DXMatrixScaling( &m_MatScale, m_ControlScale[0], m_ControlScale[1], m_ControlScale[2] );


	D3DXMatrixRotationX( &m_MatRotate[0], m_ControlRotate[0]  );
	D3DXMatrixRotationY( &m_MatRotate[1], m_ControlRotate[1]  );
	D3DXMatrixRotationZ( &m_MatRotate[2], m_ControlRotate[2]  );


	D3DXMatrixTranslation( &m_MatTranslate, m_ControlTranslate[0], m_ControlTranslate[1], m_ControlTranslate[2] );

	m_MatWorld = m_MatScale * m_MatRotate[0] * m_MatRotate[1] * m_MatRotate[2] * m_MatTranslate;

	return m_MatWorld;
}
